import java.io.*;
import java.sql.*;
import java.util.*;

import local.util.MyPrint;

public class TickListById {

    public static void main (String args[]) {

	if (args.length == 0) {
	    MyPrint.printLine("=",100);
	    System.out.println("[1][Sector Id][EX]");
	    System.out.println("[2][Sector Id][Indystry Id][]EX");
	    MyPrint.printLine("=",100);
	    
	    System.exit(0);
	}

	String tick = null;
	String sid = null;
	String iid = null;
	String exchange = null;

	TickListById tl = new TickListById ();

	tick = args[0];
	if (args[0].equals("1")) {
	    sid = args[1];
	    exchange = args[2];
	    if (exchange.equals("0")) {
		tl.printTickList(tick, sid);
	    }
	    else if(exchange.equals("15")) {
		tl.printNazTickList(tick, sid);
	    }
	    else {
		return;
	    }
	}

	if (args[0].equals("2")) {
	    sid = args[1];
	    iid = args[2];
	    exchange = args[3];
	    if (exchange.equals("0")) {
		tl.printTickList(tick, sid, iid);
	    }
	    else if (exchange.equals("15")) {
		tl.printNazTickList(tick, sid, iid);
	    }
	    else {
		return;
	    }
	}
    }

    private void printTickList (String tick, String sid, String iid) {

	String my_query_string = null;
	DataBaseQuery my_query = new DataBaseQuery ();
	Vector t_record_v = new Vector();

	my_query_string   = "SELECT Tick FROM Tick WHERE Industry_Id="+iid+" and  Sector_Id="+sid;
	my_query.lookup ( my_query_string );
	t_record_v = my_query.getTableRecordVector();
	MyPrint.printVectorVector(t_record_v,1);
    }

    private void printTickList (String tick, String sid) {

	String my_query_string = null;
	DataBaseQuery my_query = new DataBaseQuery ();
	Vector t_record_v = new Vector();

	my_query_string   = "SELECT Tick FROM Tick WHERE Sector_Id="+sid;
	my_query.lookup ( my_query_string );
	t_record_v = my_query.getTableRecordVector();
	MyPrint.printVectorVector(t_record_v,1);
    }

    private void printNazTickList (String tick, String sid, String iid) {

	String my_query_string = null;
	DataBaseQuery my_query = new DataBaseQuery ();
	Vector t_record_v_v = new Vector();
	Vector t_record_v = new Vector();
	String temp = null;
	my_query_string   = "SELECT Tick FROM Tick WHERE Industry_Id="+iid+" and  Sector_Id="+sid;
	my_query.lookup ( my_query_string );
	t_record_v_v = my_query.getTableRecordVector();
	//MyPrint.printVectorVector(t_record_v_v,1);

	Enumeration enum1 = t_record_v_v.elements();
	while (enum1.hasMoreElements()) {
	    t_record_v = (Vector)enum1.nextElement();
	    Enumeration enum2 = t_record_v.elements();
	    while (enum2.hasMoreElements()) {
		temp = (String)enum2.nextElement();
		if (temp.length() == 4) {
		    System.out.println(temp);
		}
	    }
	}
    }

    private void printNazTickList (String tick, String sid) {

	String my_query_string = null;
	DataBaseQuery my_query = new DataBaseQuery ();
	Vector t_record_v_v = new Vector();
	Vector t_record_v = new Vector();
	String temp = null;
	my_query_string   = "SELECT Tick FROM Tick WHERE Sector_Id="+sid;
	my_query.lookup ( my_query_string );
	t_record_v_v = my_query.getTableRecordVector();
	//MyPrint.printVectorVector(t_record_v_v,1);

	Enumeration enum1 = t_record_v_v.elements();
	while (enum1.hasMoreElements()) {
	    t_record_v = (Vector)enum1.nextElement();
	    Enumeration enum2 = t_record_v.elements();
	    while (enum2.hasMoreElements()) {
		temp = (String)enum2.nextElement();
		if (temp.length() == 4) {
		    System.out.println(temp);
		}
	    }
	}
    }
}









